package com.ysten.basic.service.business;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.ysten.basic.bean.entity.business.Picture;
import com.ysten.basic.bean.entity.system.SystemConfig;
import com.ysten.basic.bean.repository.business.PictureDao;
import com.ysten.basic.common.utils.PageUtil;

/**
 * <功能详细描述>
 * 
 * @author 陆小凤
 * @version [1.0, 2015年12月9日]
 */
@Component
@Transactional(value = "transactionManager")
public class PictureService
{
    @Autowired
    private PictureDao pictureDao;
    
    /**
     * <分页查询配置信息>
     * 
     * @param searchParams
     * @param pageNumber
     * @param pageSize
     * @return
     */
    public Page<Picture> getPictureList(Map<String, Object> searchParams, int pageNumber, int pageSize)
    {
        PageRequest pageRequest = PageUtil.buildPageRequest(pageNumber, pageSize);
        Specification<Picture> spec = PageUtil.buildSpecification(searchParams, Picture.class);
        return pictureDao.findAll(spec, pageRequest);
    }
    
    public void save(Picture picture)
    {
        pictureDao.save(picture);
    }
    
    public Picture getPictureById(Long id)
    {
        return pictureDao.findOne(id);
    }
    
    public void deleteById(Long id)
    {
        pictureDao.delete(id);
    }
    
}